<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 先显示占位图
        // 派一个代理对象去请求真实的图片地址
        // 交给这个对象
        var myImg = (function() {
            var imgNode = document.createElement('img');
            document.body.appendChild(imgNode);
            return {
                setSrc: function(src) {
                    imgNode.src = src
                }
            }
        })()
        var proxyImage = (function() {
            var img = new Image(); //DOM代理对象
            img.onload = function() {
                myImg.setSrc(this.src)
            }
            return {
                setSrc: function(src) {
                    // console.log(src);
                    myImg.setSrc("https://tse1-mm.cn.bing.net/th/id/R-C.ff5b20454be33e8b10d9bcf371f2d809?rik=%2bvXQdMWOYzv1Uw&riu=http%3a%2f%2fimages.shejidaren.com%2fwp-content%2fuploads%2f2015%2f11%2floading-gif-9.gif&ehk=esabIPgHd5tCMEZhmuvgEJhzHqWEMljYZstP9nIZyYQ%3d&risl=&pid=ImgRaw&r=0")
                    img.src = src;
                }
            }
        })()
        proxyImage.setSrc('https://tse1-mm.cn.bing.net/th/id/OIP-C.NhG1WHLCv6ixi3LC243ovwHaNK?pid=ImgDet&rs=1');
    </script>
</body>

</html>